home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / emulator / bsvc-1.000 / bsvc-1 / bsvc-1.0.4 / src / UI / main.tk < prev    next >
Text File  |  1995-07-26  |  44KB  |  1,257 lines

  1. #!/usr/local/bin/wish -f
  2. ###############################################################################
  3. # $Id: main.tk,v 1.6 1995/06/29 23:06:56 bmott Exp $
  4. ###############################################################################
  5. # main.tk - BSVC user interface
  6. #
  7. # Copyright 1993
  8. # Bradford W. Mott
  9. # September 18,1993
  10. ###############################################################################
  11. # $Log: main.tk,v $
  12. # Revision 1.6  1995/06/29  23:06:56  bmott
  13. # Fixed "Insert Registers..." in trace window bug
  14. #
  15. # Revision 1.5  1995/01/01  02:59:39  bmott
  16. # Added Home Page option to the help menu and changed the version number
  17. #
  18. # Revision 1.4  1994/09/13  23:25:10  bmott
  19. # Changed file selector to BtkFileSelector.
  20. # Modified trace preferences to fill the width of the window.
  21. #
  22. # Revision 1.3  1994/08/22  07:43:31  bmott
  23. # Modified startup of the program to see if a setup file should be loaded
  24. #
  25. # Revision 1.2  1994/06/23  00:20:12  bmott
  26. # Changed the breakpoint dialog to be a child of the main window.
  27. # Changed the name of some of the buttons on the Edit Setup dialog.
  28. #
  29. # Revision 1.1  1994/02/18  20:29:29  bmott
  30. # Initial revision
  31. #
  32. ###############################################################################
  33.  
  34.  
  35. ## Include utilities
  36. source $Program(LibDir)/BtkFileSelector.tk
  37. source $Program(LibDir)/memory.tk
  38. source $Program(LibDir)/listing.tk
  39. source $Program(LibDir)/tools.tk
  40. source $Program(LibDir)/help.tk
  41.  
  42. ## Important globals
  43. set Program(Name)    "BSVC"
  44. set Program(Version) "1.1"
  45.  
  46. set Simulator(Prompt)   "Ready!"
  47.  
  48. wm title      . "$Program(Name)"
  49. wm iconname   . $Program(Name)
  50. wm iconbitmap . "@$Program(BitmapDir)/bsvc_icon.xbm"
  51. wm grid       . 1 1 1 1
  52.  
  53.  
  54. ###############################################################################
  55. # Called when the user selects the quit menu options 
  56. ###############################################################################
  57. proc QuitBSVC {} {
  58.   StopSimulator
  59.   exit
  60. }
  61.  
  62. ###############################################################################
  63. # The About Dialog
  64. ###############################################################################
  65. proc About {} {
  66.   global Program
  67.  
  68.   catch {destroy .about}
  69.   toplevel .about
  70.   wm title .about "About $Program(Name)"
  71.   wm iconname .about "About $Program(Name)"
  72.  
  73.   label .about.bmott -relief raised -bitmap @$Program(BitmapDir)/b-logo.xbm
  74.  
  75.   frame .about.bsvc -relief flat -borderwidth 2
  76.     label .about.bsvc.bitmap -relief raised -bitmap @$Program(BitmapDir)/bsvc.xbm
  77.     message .about.bsvc.message1 \
  78.         -text "A Microprocessor Simulation Framework" \
  79.         -width 3i -justify center
  80.     message .about.bsvc.message2 \
  81.         -text "By: Bradford W. Mott" \
  82.         -width 3i -justify center
  83.     message .about.bsvc.message3 \
  84.         -text "Copyright (c) 1993,1994,1995\n\nVersion $Program(Version)" \
  85.         -width 3i -justify center
  86.     button .about.bsvc.ok -text "Okay" -command "destroy .about"
  87.     pack .about.bsvc.bitmap -side top -padx 2 -pady 2
  88.     pack .about.bsvc.message1 -side top -padx 2 -pady 6
  89.     pack .about.bsvc.message2 -side top -padx 2 -pady 6
  90.     pack .about.bsvc.message3 -side top -padx 2 -pady 6
  91.     pack .about.bsvc.ok -side bottom -padx 2 -pady 2 -fill x
  92.  
  93.   pack .about.bmott -side left -padx 2 -pady 2 -fill y -expand 1
  94.   pack .about.bsvc -side left -padx 2 -pady 2 -fill y -expand 1
  95. }
  96.  
  97. ###############################################################################
  98. # Set the application's widgets to the correct mode
  99. ###############################################################################
  100. proc SetApplicationMode {mode} {
  101.   if {$mode=="SimulationMode"} {
  102.     .mainMenu.simulator configure -state normal
  103.     .mainMenu.simulator.menu enable "Save Setup..."
  104.     .mainMenu.simulator.menu enable "Edit Setup..."
  105.     .mainMenu.system configure -state normal
  106.     .mainMenu.help configure -state normal
  107.     .systemResources.registers.popup configure -state normal
  108.     .systemResources.statistics.popup configure -state normal
  109.     .systemControl.singleStep configure -state normal
  110.     .systemControl.step configure -state normal
  111.     .systemControl.run configure -state normal
  112.     .systemControl.breakpoints configure -state normal
  113.     .systemOutput.popup configure -state normal
  114.   }
  115.   if {$mode=="StartupMode"} {
  116.     .mainMenu.simulator configure -state normal
  117.     .mainMenu.simulator.menu disable "Save Setup..."
  118.     .mainMenu.simulator.menu disable "Edit Setup..."
  119.     .mainMenu.system configure -state disabled
  120.     .mainMenu.help configure -state normal
  121.     .systemResources.registers.popup configure -state disabled
  122.     .systemResources.statistics.popup configure -state disabled
  123.     .systemControl.singleStep configure -state disabled
  124.     .systemControl.step configure -state disabled
  125.     .systemControl.run configure -state disabled
  126.     .systemControl.breakpoints configure -state disabled
  127.     .systemOutput.popup configure -state disabled
  128.   } 
  129. }
  130.  
  131. ###############################################################################
  132. # Send a line of input to the simulator
  133. ###############################################################################
  134. proc PutLine {line} {
  135.   global Simulator
  136.  
  137.   puts $Simulator(Pipe) $line
  138.   flush $Simulator(Pipe)
  139. }
  140.  
  141. ###############################################################################
  142. # Get a line of output from the simulator
  143. ###############################################################################
  144. proc GetLine {} {
  145.   global Simulator
  146.  
  147.   return [gets $Simulator(Pipe)]
  148. }
  149.  
  150. ###############################################################################
  151. # Get a list of output from the simulator
  152. ###############################################################################
  153. proc GetList {} {
  154.   global Simulator
  155.  
  156.   set list ""
  157.  
  158.   while {1} {
  159.     set input [gets $Simulator(Pipe)]
  160.     if {[string compare $input $Simulator(Prompt)]!="0"} {
  161.       lappend list "$input"
  162.     } else {
  163.       return $list
  164.     }
  165.   }
  166. }
  167.  
  168. ###############################################################################
  169. # Stop the simulator and clean up
  170. ###############################################################################
  171. proc StopSimulator {} {
  172.   global Simulator
  173.  
  174.   ## Change application to startup mode
  175.   SetApplicationMode {StartupMode}
  176.  
  177.   ## Shutdown the simulator process by sending Exit Command
  178.   catch {PutLine "Exit"}
  179.   catch {unset Simulator(Pid)}
  180.  
  181.   ## Close the pipe to the simulator
  182.   catch {close $Simulator(Pipe)}
  183.   catch {unset Simulator(Pipe)}
  184.  
  185.   ## destory old values
  186.   catch {unset Simulator(ProgramName)}
  187.   catch {unset Simulator(Greeting)}
  188.   catch {unset Simulator(NumberOfAddressSpaces)}
  189.   catch {unset Simulator(Granularity)}
  190.   catch {unset Simulator(TraceRecord)}
  191.   catch {unset Simulator(TraceEntries)}
  192.  
  193.   ## Clean up the windows
  194.   .systemResources.registers.list delete 0 end
  195.   .systemResources.statistics.list delete 0 end
  196.   .systemOutput.text delete 1.0 end
  197.  
  198.   ## Close down the memory and program listing windows
  199.   CloseMemoryViewer
  200.   CloseProgramListing
  201. }
  202.  
  203. ###############################################################################
  204. # Start the simulator
  205. ###############################################################################
  206. proc StartSimulator {name} {
  207.   global Simulator
  208.   global env
  209.  
  210.   ## Check to make sure the simulator exists and is executable
  211.   set paths [concat . [split "$env(PATH)" ":"]]
  212.   set does_not_exists 1
  213.   foreach i $paths {
  214.     if {[file executable $i/$name] && [file isfile $i/$name]} {
  215.       set does_not_exists 0
  216.     }
  217.   }
  218.  
  219.   if {$does_not_exists} {
  220.     ChildAlertDialog {} "Could not find the requested simulator to execute!!!\n\n($name)"
  221.     return 0
  222.   }
  223.  
  224.   ## Open a pipe to the simulator (read & write)
  225.   if {[catch {open "|$name" "r+"} Simulator(Pipe)]} {
  226.     catch {close $Simulator(Pipe)}
  227.     ChildAlertDialog {} {Problem opening pipe to the simulator!!!}
  228.     return 0 
  229.   }
  230.  
  231.   ## Make sure the program is a BSVC Simulator!!!
  232.   if {[string compare [GetLine] "BSVC Simulator"]!=0} {
  233.     close $Simulator(Pipe)  
  234.     ChildAlertDialog {} {That program does not seem to be a valid BSVC simulator!!!}
  235.     return 0
  236.   } else {
  237.     set Simulator(ProgramName) "$name"
  238.     set Simulator(Greeting) [GetList]
  239.  
  240.     set Simulator(Pid) [pid $Simulator(Pipe)]
  241.     PutLine "ListNumberOfAddressSpaces"
  242.     set Simulator(NumberOfAddressSpaces) [lindex [GetList] 0]
  243.  
  244.     PutLine "ListGranularity"
  245.     set Simulator(Granularity) [lindex [GetList] 0]
  246.  
  247.     PutLine "ListExecutionTraceRecord"
  248.     set Simulator(TraceRecord) [lindex [GetList] 0]
  249.  
  250.     PutLine "ListDefaultExecutionTraceEntries"
  251.     set Simulator(TraceEntries) [lindex [GetList] 0]
  252.  
  253.     return 1
  254.   }
  255. }
  256.  
  257. ###############################################################################
  258. # Detach all of the devices from the given address space
  259. ###############################################################################
  260. proc DetachAllDevices {address_space} {
  261.  
  262.   ## Get a list of all attached devices
  263.   PutLine "ListAttachedDevices $address_space"
  264.   set number_of_devices [llength [GetList]]
  265.  
  266.   ## Remove each device from the address space
  267.   for {set t [expr $number_of_devices-1]} {$t>=0} {set t [expr $t-1]} {
  268.     ## Send the detach command to the simulator
  269.     PutLine "DetachDevice $address_space $t"
  270.  
  271.     ## Output any errors to the user
  272.     set errs [lindex [GetList] 0]
  273.     if {$errs!=""} { ChildAlertDialog {} $errs }
  274.   }
  275. }
  276.  
  277. ###############################################################################
  278. # Detach the indexed device from the simulator 
  279. ###############################################################################
  280. proc DetachDevice {address_space index} {
  281.  
  282.   ## Send the detach command to the simulator
  283.   PutLine "DetachDevice $address_space $index"
  284.  
  285.   ## Output any errors to the user 
  286.   set errs [lindex [GetList] 0]
  287.   if {$errs!=""} { ChildAlertDialog {} $errs }
  288. }
  289.  
  290. ###############################################################################
  291. # Attach the named device to the simulator 
  292. ###############################################################################
  293. proc AttachDevice {address_space name} {
  294.  
  295.   ## Get the device's script
  296.   PutLine "ListDeviceScript $name"
  297.   set script [GetList]
  298.  
  299.   ## Get the script in a form that can be executed by 'eval'
  300.   set t ""
  301.   foreach i $script { set t "$t\n$i" }
  302.  
  303.   ## Evaluate the script and execute the device setup
  304.   if {[catch {eval "$t"}]==0} {
  305.     ## Call the DeviceSetup procedure that should have just been created
  306.     set device_args [DeviceSetup]
  307.  
  308.     if {$device_args!=""} {
  309.       PutLine "AttachDevice $address_space $name \{$device_args\}"
  310.       set errs [lindex [GetList] 0]
  311.       if {$errs!=""} { ChildAlertDialog {} $errs }
  312.     }
  313.   } else {
  314.     ChildAlertDialog {} {The device script cannot be executed!!!}
  315.   }
  316. }
  317.  
  318. ###############################################################################
  319. # RefreshEditSetupLists
  320. ###############################################################################
  321. proc RefreshEditSetupLists {addr_space} {
  322.   global Simulator
  323.  
  324.   ## Empty available list
  325.   .editSetup.availableDevices.list delete 0 end
  326.  
  327.   ## Fill in the available device list  
  328.   PutLine {ListDevices}
  329.   foreach i [GetList] {
  330.     .editSetup.availableDevices.list insert end $i
  331.   }
  332.  
  333.   ## Empty attached list
  334.   .editSetup.attachedDevices.list delete 0 end
  335.  
  336.   ## Fill in the attached device list
  337.   PutLine "ListAttachedDevices $addr_space"
  338.   foreach i [GetList] {
  339.     .editSetup.attachedDevices.list insert end $i
  340.   }
  341. }
  342.  
  343. ###############################################################################
  344. # Change the edit setup address space 
  345. ###############################################################################
  346. proc ChangeEditSetupAddressSpace {value} {
  347.   global CurrentEditSetupAddressSpace
  348.  
  349.   set CurrentEditSetupAddressSpace $value
  350.   RefreshEditSetupLists $CurrentEditSetupAddressSpace
  351. }
  352.  
  353. ###############################################################################
  354. # Handle Edit Setup menu selection
  355. ###############################################################################
  356. proc EditSetup {} {
  357.   global Simulator
  358.   global CurrentEditSetupAddressSpace
  359.  
  360.   set CurrentEditSetupAddressSpace 0
  361.  
  362.   ## Create frame for edit dialog
  363.   frame .editSetup -relief raised -borderwidth 3
  364.  
  365.   ## Create the "Dismiss" button
  366.   button .editSetup.done -text "Dismiss" -command {destroy .editSetup}
  367.   pack .editSetup.done -side bottom -fill x -padx 4 -pady 4
  368.  
  369.   ## Create the "Attached Devices" area (list,scroll, & buttons)
  370.   frame .editSetup.attachedDevices
  371.     label .editSetup.attachedDevices.label -text "Attached Devices" \
  372.         -relief raised
  373.     scrollbar .editSetup.attachedDevices.scroll -relief raised \
  374.         -command ".editSetup.attachedDevices.list yview"
  375.     listbox .editSetup.attachedDevices.list -relief raised \
  376.         -yscroll ".editSetup.attachedDevices.scroll set"
  377.     tk_listboxSingleSelect .editSetup.attachedDevices.list
  378.     frame .editSetup.attachedDevices.buttons
  379.       button .editSetup.attachedDevices.buttons.remove -text "Detach" \
  380.           -command {
  381.              if {[llength [.editSetup.attachedDevices.list curselection]]!=0} {
  382.                DetachDevice $CurrentEditSetupAddressSpace \
  383.                 [.editSetup.attachedDevices.list curselection] ;
  384.                RefreshEditSetupLists $CurrentEditSetupAddressSpace ;
  385.                RefreshMemoryViewer
  386.              }
  387.            }
  388.       button .editSetup.attachedDevices.buttons.removeAll -text "Detach All" \
  389.           -command {DetachAllDevices $CurrentEditSetupAddressSpace ;
  390.                     RefreshEditSetupLists $CurrentEditSetupAddressSpace;
  391.                     RefreshMemoryViewer}
  392.       pack .editSetup.attachedDevices.buttons.remove -side left \
  393.           -fill x -expand 1
  394.       pack .editSetup.attachedDevices.buttons.removeAll -side left \
  395.           -fill x -expand 1
  396.     pack .editSetup.attachedDevices.label -side top -fill x
  397.     pack .editSetup.attachedDevices.buttons -side bottom -fill x -expand 1
  398.     pack .editSetup.attachedDevices.scroll -side left -fill y
  399.     pack .editSetup.attachedDevices.list -side left -fill y
  400.  
  401.   ## Create the "Available Devices" area (list,scroll, & buttons)
  402.   frame .editSetup.availableDevices
  403.     label .editSetup.availableDevices.label -text "Available Devices" \
  404.         -relief raised
  405.     scrollbar .editSetup.availableDevices.scroll -relief raised \
  406.         -command ".editSetup.availableDevices.list yview"
  407.     listbox .editSetup.availableDevices.list -relief raised \
  408.         -yscroll ".editSetup.availableDevices.scroll set"
  409.     tk_listboxSingleSelect .editSetup.availableDevices.list
  410.     bind .editSetup.availableDevices.list <Double-1> {
  411.             if {[llength [.editSetup.availableDevices.list curselection]]!=0} {
  412.               AttachDevice $CurrentEditSetupAddressSpace \
  413.                 [.editSetup.availableDevices.list get \
  414.                 [.editSetup.availableDevices.list curselection]] ;
  415.               RefreshEditSetupLists $CurrentEditSetupAddressSpace ;
  416.               RefreshMemoryViewer
  417.             }
  418.           }
  419.     frame .editSetup.availableDevices.buttons
  420.       button .editSetup.availableDevices.buttons.add -text "Attach" \
  421.           -command {
  422.             if {[llength [.editSetup.availableDevices.list curselection]]!=0} {
  423.               AttachDevice $CurrentEditSetupAddressSpace \
  424.                [.editSetup.availableDevices.list get \
  425.                [.editSetup.availableDevices.list curselection]];
  426.                RefreshEditSetupLists $CurrentEditSetupAddressSpace ;
  427.                RefreshMemoryViewer
  428.             }
  429.           }
  430.       pack .editSetup.availableDevices.buttons.add -side left \
  431.           -fill x -expand 1
  432.     pack .editSetup.availableDevices.label -side top -fill x
  433.     pack .editSetup.availableDevices.buttons -side bottom -fill x -expand 1
  434.     pack .editSetup.availableDevices.scroll -side left -fill y
  435.     pack .editSetup.availableDevices.list -side left -fill y
  436.  
  437.   pack .editSetup.attachedDevices -side left -padx 4 -pady 4
  438.   pack .editSetup.availableDevices -side left -padx 4 -pady 4
  439.  
  440.   ## If there are multiple address spaces then create a scale
  441.   if {$Simulator(NumberOfAddressSpaces) > 1} {
  442.     frame .editSetup.addressSpace
  443.       label .editSetup.addressSpace.label -text "Address Space" \
  444.           -relief raised
  445.       scale .editSetup.addressSpace.scale -from 0 -showvalue 1 \
  446.           -tickinterval 1 -to [expr $Simulator(NumberOfAddressSpaces)-1] \
  447.           -relief raised -command {ChangeEditSetupAddressSpace}
  448.       pack .editSetup.addressSpace.label -side top -fill x
  449.       pack .editSetup.addressSpace.scale -side top -fill both -expand 1
  450.  
  451.     pack .editSetup.addressSpace -side left -fill y -padx 4 -pady 4
  452.   }
  453.  
  454.   place .editSetup -relx 0.5 -rely 0.5 -anchor center
  455.  
  456.   RefreshEditSetupLists $CurrentEditSetupAddressSpace
  457.  
  458.   ## Make this a modal dialog
  459.   tkwait visibility .editSetup
  460.   grab set .editSetup
  461.   tkwait window .editSetup
  462. }
  463.  
  464.  
  465. ###############################################################################
  466. # Handle New Setup (Ask for simulator's name and goto edit screen)
  467. ###############################################################################
  468. proc NewSetup {} {
  469.   global Simulator
  470.  
  471.   ## Shutdown any running simulator
  472.   StopSimulator
  473.  
  474.   ## Set the application to startup mode
  475.   SetApplicationMode {StartupMode}
  476.  
  477.   set ReturnValue [ChildEntryDialog \
  478.       {} {What simulator do you want to use? (i.e. Sim68000)} {[.]*}]
  479.  
  480.   ## Check to see if cancel was pressed
  481.   if {[string length $ReturnValue]==0} {
  482.     return
  483.   } else {
  484.     ## Attempt to start the simulator process
  485.     if {[StartSimulator $ReturnValue]} {
  486.       SetApplicationMode {SimulationMode}
  487.  
  488.       ## Decided if the statistics list should be displayed
  489.       if {[RefreshStatisticsList] == "0"} {
  490.         pack forget .systemResources.statistics
  491.       } else {
  492.         pack .systemResources.statistics -after .systemResources.registers \
  493.             -side left -fill y
  494.       }
  495.       RefreshRegisterList
  496.       EditSetup
  497.     } else {
  498.     }
  499.   }
  500. }
  501.  
  502. ###############################################################################
  503. # Clear the simulator's Statistics
  504. ###############################################################################
  505. proc ClearStatistics {} {
  506.  
  507.   ## Tell the simulator to clear the statistics
  508.   PutLine {ClearStatistics}
  509.   GetList
  510.  
  511.   ## Update the statistics list
  512.   RefreshStatisticsList
  513. }
  514.  
  515. ###############################################################################
  516. # Refresh the Statistics List (returns 0 if a list does not exists)
  517. ###############################################################################
  518. proc RefreshStatisticsList {} {
  519.   global ReturnValue
  520.  
  521.   ## Get the geometry of the register list
  522.   if {[scan [.systemResources.statistics.list configure -geometry] \
  523.       "-geometry geometry Geometry %s %d\x%d" dummy w h]!=3} {
  524.     set w 20
  525.     set h 10
  526.   }
  527.  
  528.   ## Get the list of statistics from the simulator
  529.   PutLine {ListStatistics}
  530.  
  531.   set stat_list [GetList]
  532.   if {[llength $stat_list] == 0} { return 0 }
  533.  
  534.   .systemResources.statistics.list delete 0 end 
  535.   foreach i $stat_list {
  536.     .systemResources.statistics.list insert end "$i"
  537.  
  538.     ## Adjust the statistics list geometry if necessary
  539.     if {$w<[string length $i]} {
  540.       set w [expr [string length $i]+1]
  541.       .systemResources.statistics.list configure -geometry "$w\x$h"
  542.     }
  543.   }
  544.   return 1
  545. }
  546.  
  547. ###############################################################################
  548. # Refresh the Register List
  549. ###############################################################################
  550. proc RefreshRegisterList {} {
  551.   global ReturnValue
  552.  
  553.   ## Get the geometry of the register list
  554.   if {[scan [.systemResources.registers.list configure -geometry] \
  555.       "-geometry geometry Geometry %s %d\x%d" dummy w h]!=3} {
  556.     set w 20
  557.     set h 10
  558.   }
  559.  
  560.   ## Get the list of registers and values from the simulator
  561.   PutLine {ListRegisters}
  562.  
  563.   .systemResources.registers.list delete 0 end 
  564.   foreach i [GetList] {
  565.     .systemResources.registers.list insert end "$i"
  566.  
  567.     ## Adjust the register list geometry if necessary
  568.     if {$w<[string length $i]} {
  569.       set w [expr [string length $i]+1]
  570.       .systemResources.registers.list configure -geometry "$w\x$h"
  571.     }
  572.   }
  573. }
  574.   
  575.  
  576. ###############################################################################
  577. # Clear all of the registers (set them to zero)
  578. ###############################################################################
  579. proc ClearAllRegisters {} {
  580.   
  581.   ## Set each of the registers to 0
  582.   PutLine {ListRegisters}
  583.   foreach i [GetList] {
  584.     scan $i "%s" name
  585.     PutLine "SetRegister $name 0"
  586.     ## Remove any simulator output (should be just a Ready)
  587.     GetList 
  588.   }
  589.   RefreshStatisticsList 
  590.   RefreshRegisterList
  591.   RefreshProgramListing
  592. }
  593.  
  594. ###############################################################################
  595. # Alter the value of a register
  596. ###############################################################################
  597. proc AlterRegister {} {
  598.  
  599.   ## If no register is selected then leave
  600.   if {[llength [.systemResources.registers.list curselection]]==0} {
  601.     return
  602.   }
  603.  
  604.   ## Get the register name
  605.   scan [.systemResources.registers.list get [.systemResources.registers.list \
  606.        curselection]] "%s" name
  607.  
  608.   set ReturnValue [ChildEntryDialog {} \
  609.       "Enter new value for register '$name':" {^[0-9a-fA-F]+$}]
  610.  
  611.   # If Okay was pressed set the register value in the simulator
  612.   if {$ReturnValue != ""} {
  613.     PutLine "SetRegister $name $ReturnValue"
  614.     GetList
  615.     RefreshStatisticsList
  616.     RefreshRegisterList
  617.     RefreshProgramListing
  618.   }
  619. }
  620.  
  621. ###############################################################################
  622. # Insert the statistics list into the trace window
  623. ###############################################################################
  624. proc InsertStatisticsInTrace {} {
  625.  
  626.   ## Get the statistics list and put it in the trace window
  627.   PutLine {ListStatistics}
  628.  
  629.   foreach i [GetList] {
  630.     .systemOutput.text insert end "$i\n" 
  631.     .systemOutput.text yview -pickplace end
  632.   } 
  633. }
  634.   
  635. ###############################################################################
  636. # Insert the register list into the trace window
  637. ###############################################################################
  638. proc InsertRegistersInTrace {} {
  639.  
  640.   ## Get the width of the trace window
  641.   if {[scan [.systemOutput.text configure -width] \
  642.             "-width width Width 80 %d" width] != "1"} {
  643.     set width "60"
  644.   } 
  645.  
  646.   ## Get the register list and put it in the trace window
  647.   PutLine {ListRegisters}
  648.   set line ""
  649.   foreach i [GetList] {
  650.     if {[expr [string length $i]+[string length $line]]>$width} {
  651.       .systemOutput.text insert end "$line\n" 
  652.       .systemOutput.text yview -pickplace end
  653.       set line "$i"  
  654.     } else {
  655.       if {[string length $line]!=0} {
  656.         set line "$line $i"
  657.       } else {
  658.         set line "$i"
  659.       }
  660.     }
  661.   }
  662.  
  663.   ## Add the last line if there is one  
  664.   if {[string length $line]!=0} {
  665.     .systemOutput.text insert end "$line\n\n" 
  666.     .systemOutput.text yview -pickplace end
  667.   } else {
  668.     .systemOutput.text insert end "\n"
  669.     .systemOutput.text yview -pickplace end
  670.   }
  671. }
  672.  
  673. ###############################################################################
  674. # Save the contents of the trace window to a file
  675. ###############################################################################
  676. proc SaveTraceContents {} {
  677.  
  678.   ## Get the filename
  679.   set name [BtkFileSelector -text "Select file to append trace contents to:" \
  680.       -in .]
  681.  
  682.   if {$name != ""} {
  683.     if {[file isdirectory $name]} {
  684.       ChildAlertDialog {} {ERROR: The name specified was a directory!!!}
  685.       return
  686.     }
  687.  
  688.     set file [open $name "a+"]
  689.     set contents [.systemOutput.text get 1.0 end]
  690.     puts $file "$contents"
  691.     close $file
  692.   }
  693. }
  694.  
  695. ###############################################################################
  696. # Load a program into the simulator
  697. ###############################################################################
  698. proc LoadProgram {} {
  699.   set name [BtkFileSelector -text "Select program to load:" -in .]
  700.  
  701.   if {$name!=""} {
  702.     if {[file isdirectory $name]} {
  703.       ChildAlertDialog {} {ERROR: The name specified was a directory!!!}
  704.       return
  705.     }
  706.  
  707.     ## Tell the simulator to load in the program
  708.     PutLine "LoadProgram 0 $name"
  709.  
  710.     ## Get any error message from the simulator and display it
  711.     set mess [lindex [GetList] 0]
  712.     if {$mess!=""} {
  713.       ChildAlertDialog {} "$mess"
  714.     }
  715.     RefreshMemoryViewer
  716.   }
  717. }
  718.  
  719. ###############################################################################
  720. # Insert the execution trace record into the output window
  721. ###############################################################################
  722. proc InsertStepTraceRecord {record} {
  723.   global Simulator
  724.  
  725.   ## Add the SimulatorMessage to the possible records/entries
  726.   set trace_records "{SimulatorMessage 40} $Simulator(TraceRecord)"
  727.   set entries "SimulatorMessage $Simulator(TraceEntries)"
  728.  
  729.   foreach i $trace_records {
  730.     if {[scan $i "%s %d" name width]==2} { 
  731.       if {[lsearch $entries $name] != -1} {
  732.         set i [lsearch -regexp $record "^$name"]
  733.         if {$i != -1} {
  734.           set field [lindex $record $i]
  735.           set t [format "%-$width\s" "[lindex $field 1]"]
  736.           .systemOutput.text insert end "$t "
  737.           .systemOutput.text yview -pickplace end
  738.         }
  739.       }
  740.     } 
  741.   }
  742.   .systemOutput.text insert end "\n"
  743.   .systemOutput.text yview -pickplace end
  744. }
  745.  
  746. ###############################################################################
  747. # Do a system reset on the simulator
  748. ###############################################################################
  749. proc Reset {} {
  750.  
  751.   PutLine "Reset"
  752.   GetList
  753.  
  754.   ## Refresh windows
  755.   RefreshStatisticsList
  756.   RefreshRegisterList
  757.   RefreshProgramListing
  758.   RefreshMemoryViewer
  759. }
  760.  
  761. ###############################################################################
  762. # Step through some number of instructions
  763. ###############################################################################
  764. proc Step {number} {
  765.  
  766.   PutLine "Step $number"
  767.   foreach i [GetList] {
  768.      InsertStepTraceRecord "$i"
  769.   }
  770.  
  771.   ## Refresh windows
  772.   RefreshStatisticsList
  773.   RefreshRegisterList
  774.   RefreshProgramListing
  775.   RefreshMemoryViewer
  776. }
  777.  
  778. ###############################################################################
  779. # Handle Running
  780. ###############################################################################
  781. proc Run {} {
  782.   global Simulator
  783.  
  784.   ## Just in case destroy the window
  785.   catch {destroy .runningButton}
  786.  
  787.    button .runningButton -text "Interrupt Execution!" \
  788.       -command {
  789.           ## Send interrupt signal to the simulator
  790.           exec kill -INT $Simulator(Pid)
  791.           destroy .runningButton
  792.         }
  793.  
  794.   place .runningButton -relx 0.5 -rely 0.5 \
  795.       -anchor center -relheight 0.2 -relwidth 0.4
  796.  
  797.   ## Wait for the window to become visibile
  798.   tkwait visibility .runningButton
  799.  
  800.   ## If input becomes availiable on the pipe then execution has stopped!
  801.   addinput -read $Simulator(Pipe) {destroy .runningButton}
  802.  
  803.   ## Start the program running
  804.   PutLine "Run"
  805.  
  806.   ## Make this a modal dialog
  807.   while {[catch {grab set .runningButton}] == 1} {}
  808.   tkwait window .runningButton
  809.  
  810.   ## Remove the input callback on the pipe file id
  811.   removeinput $Simulator(Pipe)
  812.  
  813.   ## Insert output from the simulator into the output window
  814.   foreach i [GetList] {
  815.    .systemOutput.text insert end "$i\n"
  816.    .systemOutput.text yview -pickplace end
  817.   }    
  818.  
  819.   ## Refresh the Registers
  820.   RefreshStatisticsList
  821.   RefreshRegisterList
  822.   RefreshProgramListing
  823.  
  824.   ## Refresh the Registers
  825.   RefreshMemoryViewer
  826. }
  827.  
  828.  
  829. ###############################################################################
  830. # Refresh the list of breakpoints
  831. ###############################################################################
  832. proc RefreshBreakpoints {} {
  833.  
  834.   PutLine "ListBreakpoints"
  835.   .breakpoints.list.list delete 0 end
  836.  
  837.   foreach i [lsort -ascii [GetList]] {
  838.     .breakpoints.list.list insert end "$i"
  839.   }
  840. }
  841.  
  842. ###############################################################################
  843. # Break Point manipulation
  844. ###############################################################################
  845. proc Breakpoints {} {
  846.  
  847.   ## Make sure the window is destroyed
  848.   catch {destroy .breakpoints}
  849.  
  850.   ## Create frame for breakpoint dialog
  851.   frame .breakpoints -relief raised -borderwidth 3
  852.  
  853.   ## Create the list of break points
  854.   frame .breakpoints.list
  855.     scrollbar .breakpoints.list.scroll -relief raised \
  856.         -command ".breakpoints.list.list yview"
  857.     listbox .breakpoints.list.list -relief raised \
  858.         -yscroll ".breakpoints.list.scroll set"
  859.     pack .breakpoints.list.scroll -side left -fill y
  860.     pack .breakpoints.list.list -side left -fill both -expand 1
  861.  
  862.   ## Create the add entry box
  863.   frame .breakpoints.add -relief raised -borderwidth 2
  864.     entry .breakpoints.add.entry -relief sunken
  865.     bind .breakpoints.add.entry <Return> {
  866.         if {[regexp {^[0-9a-fA-F]*$} [.breakpoints.add.entry get]]} {
  867.           PutLine "AddBreakpoint [.breakpoints.add.entry get]"
  868.           .breakpoints.add.entry delete 0 end
  869.           GetList ; RefreshBreakpoints
  870.         }
  871.       }
  872.     label .breakpoints.add.label -text "Add:"
  873.     pack .breakpoints.add.label -side left
  874.     pack .breakpoints.add.entry -side left -fill x -expand 1
  875.  
  876.   button .breakpoints.remove -text "Remove" \
  877.       -command {
  878.           if {[llength [.breakpoints.list.list curselection]] != 0} {
  879.             foreach i [.breakpoints.list.list curselection] {
  880.               PutLine "DeleteBreakpoint [.breakpoints.list.list get $i]" 
  881.               GetList
  882.             }
  883.             RefreshBreakpoints
  884.           }
  885.         }
  886.  
  887.   button .breakpoints.dismiss -text "Dismiss" \
  888.       -command {destroy .breakpoints}
  889.  
  890.   pack .breakpoints.list -side top -expand 1 -fill both -padx 2 -pady 2
  891.   pack .breakpoints.add -side top -fill x -expand 1 -padx 2 -pady 2
  892.   pack .breakpoints.remove -side left -fill x -expand 1 -padx 2 -pady 2
  893.   pack .breakpoints.dismiss -side left -fill x -expand 1 -padx 2 -pady 2
  894.   place .breakpoints -relx 0.5 -rely 0.5 -anchor center
  895.  
  896.   ## Set keyboard focus to the entry widget
  897.   focus .breakpoints.add.entry
  898.  
  899.   RefreshBreakpoints
  900.  
  901.   ## Make this a modal dialog
  902.   tkwait visibility .breakpoints
  903.   while {[catch {grab set .breakpoints}] == 1} {}
  904.   tkwait window .breakpoints
  905. }
  906.  
  907. ###############################################################################
  908. # Set the execution trace prefrences 
  909. ###############################################################################
  910. proc TracePreferences {} {
  911.   global Simulator
  912.   global ReturnValue
  913.   global TraceCheckButton
  914.  
  915.   catch {destroy .tracePreferences}
  916.  
  917.   ## Create a frame for the dialog
  918.   frame .tracePreferences -relief raised -borderwidth 3
  919.  
  920.   message .tracePreferences.message -width 2.5i -relief raised \
  921.     -text "Select trace fields to display:"
  922.   pack .tracePreferences.message -side top -padx 2 -pady 2
  923.  
  924.   ## Build a checkbutton for each trace record field
  925.   foreach i $Simulator(TraceRecord) {
  926.     if {[scan $i "%s" name]==1} {
  927.       checkbutton .tracePreferences.checkbutton$name -text $name \
  928.           -variable TraceCheckButton($name) -relief flat -anchor w
  929.       pack .tracePreferences.checkbutton$name -side top -fill x
  930.       if {[lsearch -exact $Simulator(TraceEntries) $name] != -1} {
  931.         set TraceCheckButton($name) 1
  932.       }
  933.     }
  934.   }
  935.  
  936.   button .tracePreferences.ok -text "Okay" \
  937.       -command {set ReturnValue "Okay" ; destroy .tracePreferences}
  938.   button .tracePreferences.cancel -text "Cancel" \
  939.       -command {set ReturnValue "" ; destroy .tracePreferences}
  940.  
  941.   pack .tracePreferences.ok -side left -expand 1 -fill x -padx 2 -pady 2
  942.   pack .tracePreferences.cancel -side left -expand 1 -fill x -padx 2 -pady 2
  943.   place .tracePreferences -relx 0.5 -rely 0.5 -anchor center
  944.  
  945.   ## Make this a modal dialog
  946.   tkwait visibility .tracePreferences
  947.   grab set .tracePreferences
  948.   tkwait window .tracePreferences 
  949.  
  950.   ## If okay was pressed build the new Simulator(TraceEntries)
  951.   if {$ReturnValue!=""} {
  952.     set Simulator(TraceEntries) ""
  953.     foreach i $Simulator(TraceRecord) {
  954.       if {[scan $i "%s" name]==1} {
  955.         if {$TraceCheckButton($name) == 1} {
  956.           set Simulator(TraceEntries) "$i $Simulator(TraceEntries)"
  957.         }
  958.       }
  959.     }
  960.   } 
  961.   unset TraceCheckButton
  962. }
  963.  
  964. ###############################################################################
  965. # Load the simulator setup file and set everything up
  966. ###############################################################################
  967. proc LoadSetup {name} {
  968.   global Simulator
  969.   global Program
  970.  
  971.   ## Shutdown the simulator if it is running
  972.   StopSimulator
  973.  
  974.   ## If a name wasn't supplied then pop up a file selector
  975.   if {$name == ""} {
  976.     set name [BtkFileSelector -text "Select a setup file to load:" \
  977.         -in . -filter "*.setup"]
  978.   }
  979.  
  980.   if {$name!=""} {
  981.     if {[file exists $name] == 0} {
  982.       ChildAlertDialog {} {ERROR: Specified setup file does not exist!!!}
  983.       return
  984.     }
  985.  
  986.     if {[file isdirectory $name]} {
  987.       ChildAlertDialog {} {ERROR: Specified setup file is a directory!!!}
  988.       return
  989.     }
  990.  
  991.     set file [open $name "r"]
  992.     if {[gets $file]!="BSVC Simulator Setup File"} {
  993.       ChildAlertDialog {} "That file doesn't seem to be a simulator setup file!!!"
  994.       close $file
  995.       return
  996.     }
  997.  
  998.     ## read in the contents of the file
  999.     set contents [read $file]
  1000.     close $file
  1001.  
  1002.     if {[lsearch -exact "$contents" SIMULATOR]=="-1"} {
  1003.       ChildAlertDialog {} "The Setup file seems to be corrupt!!!"
  1004.       return
  1005.     }
  1006.     if {[StartSimulator "[lindex "$contents" [expr \
  1007.                           [lsearch -exact "$contents" SIMULATOR]+1]]"]==0} {
  1008.       return
  1009.     }
  1010.  
  1011.     while {[lsearch -exact "$contents" COMMAND]!="-1"} {
  1012.       ## Get the next command
  1013.       set index [lsearch -exact "$contents" COMMAND]
  1014.       set command [lindex "$contents" [expr $index+1]]
  1015.       ## Send the command to the simulator
  1016.       PutLine "$command"
  1017.       set errs [lindex [GetList] 0]
  1018.       ## Remove the command from the contents
  1019.       set contents [lreplace "$contents" $index [expr $index+1]]
  1020.     }
  1021.  
  1022.     SetApplicationMode {SimulationMode}
  1023.  
  1024.     ## Decided if the statistics list should be displayed
  1025.     if {[RefreshStatisticsList] == "0"} {
  1026.       pack forget .systemResources.statistics
  1027.     } else {
  1028.       pack .systemResources.statistics -after .systemResources.registers \
  1029.           -side left -fill y
  1030.     }
  1031.  
  1032.     RefreshRegisterList
  1033.   }
  1034. }
  1035.     
  1036. ###############################################################################
  1037. # Save the simulator setup to a file
  1038. ###############################################################################
  1039. proc SaveSetup {} {
  1040.   global Simulator
  1041.   global Program
  1042.  
  1043.   set name [BtkFileSelector -text "Select a file to save the setup in:" \
  1044.       -in . -filter "*.setup"]
  1045.  
  1046.   if {$name!=""} {
  1047.     if {[file isdirectory $name]} {
  1048.       ChildAlertDialog {} {ERROR: The name specified was a directory!!!}
  1049.       return
  1050.     }
  1051.  
  1052.     set file [open $name "w"]
  1053.     puts $file "BSVC Simulator Setup File"
  1054.     puts $file ""
  1055.     puts $file "UI_VERSION \{$Program(Version)\}"
  1056.     puts $file "SIMULATOR \{$Simulator(ProgramName)\}"
  1057.  
  1058.     for {set t 0} {$t<$Simulator(NumberOfAddressSpaces)} {set t [expr $t+1]} {
  1059.       ## Get a list of devices attached to this address space
  1060.       PutLine "ListAttachedDevices $t"
  1061.       foreach i [GetList] {
  1062.         puts $file "COMMAND \{AttachDevice $t $i\}" 
  1063.       }
  1064.     }
  1065.     close $file
  1066.   }
  1067.  
  1068. ###############################################################################
  1069. # Parse the command line arguments
  1070. ###############################################################################
  1071. proc ParseCommandLineArguments {} {
  1072.   global env
  1073.  
  1074.   ## Get the arguments from the environment variable
  1075.   set args $env(ARGS)
  1076.  
  1077.   ## See if a setup file was named on the command line
  1078.   if {[llength $args] == 1} {
  1079.     LoadSetup [lindex $args 0]
  1080.   }
  1081.  
  1082.   if {[llength $args] > 1} {
  1083.     ChildAlertDialog {} "Invalid number of command line arguments!!!"
  1084.   }
  1085. }
  1086.  
  1087. ###############################################################################
  1088. # Build the main drop down menu for the application
  1089. ###############################################################################
  1090. frame .mainMenu -relief raised -borderwidth 2
  1091.  
  1092.   menubutton .mainMenu.simulator -text "Simulator" -menu .mainMenu.simulator.menu
  1093.     menu .mainMenu.simulator.menu
  1094.       .mainMenu.simulator.menu add command -label "New Setup..." \
  1095.           -command {NewSetup}
  1096.       .mainMenu.simulator.menu add command -label "Load Setup..." \
  1097.           -command {LoadSetup {}}
  1098.       .mainMenu.simulator.menu add command -label "Edit Setup..." \
  1099.           -command {EditSetup}
  1100.       .mainMenu.simulator.menu add separator
  1101.       .mainMenu.simulator.menu add command -label "Save Setup..." \
  1102.           -command {SaveSetup}
  1103.       .mainMenu.simulator.menu add separator
  1104.       .mainMenu.simulator.menu add command -label "Quit"  -command "QuitBSVC"
  1105.  
  1106.   menubutton .mainMenu.system -text "System" -menu .mainMenu.system.menu
  1107.     menu .mainMenu.system.menu
  1108.       .mainMenu.system.menu add command -label "Load Program..." \
  1109.           -command {LoadProgram}
  1110.       .mainMenu.system.menu add separator
  1111.       .mainMenu.system.menu add command -label "View Memory..." \
  1112.           -command {OpenMemoryViewer}
  1113.       .mainMenu.system.menu add command -label "Program Listing..." \
  1114.           -command {OpenProgramListing}
  1115.       .mainMenu.system.menu add command -label "Reset" \
  1116.           -command {Reset}
  1117.  
  1118.   menubutton .mainMenu.help -text "Help" -menu .mainMenu.help.menu
  1119.     menu .mainMenu.help.menu
  1120.       .mainMenu.help.menu add command -label "About $Program(Name)..." \
  1121.            -command "About"
  1122.       .mainMenu.help.menu add separator
  1123.       .mainMenu.help.menu add command -label "License..." -command \
  1124.           {HelpMe "$Program(HelpDir)/license.hlp" \
  1125.               ".licenseHelp" "License"}
  1126.       .mainMenu.help.menu add command -label "General..." -command \
  1127.           {HelpMe "$Program(HelpDir)/general.hlp" \
  1128.               ".generalHelp" "General Help"}
  1129.       .mainMenu.help.menu add separator
  1130.       .mainMenu.help.menu add command -label "Home Page..." -command \
  1131.           {exec $Program(WWWBrowser) $Program(WWWHomePage) &}
  1132.  
  1133.   if {$Program(WWWBrowser) == ""} {
  1134.     .mainMenu.help.menu disable "Home Page..."
  1135.   } else {
  1136.     .mainMenu.help.menu enable "Home Page..." 
  1137.   }
  1138.  
  1139.   pack .mainMenu.simulator -side left
  1140.   pack .mainMenu.system -side left
  1141.   pack .mainMenu.help -side left
  1142.  
  1143.   tk_menuBar .mainMenu .mainMenu.simulator .mainMenu.system .mainMenu.help
  1144.  
  1145. ###############################################################################
  1146. # Build the Internal System Resource area
  1147. ###############################################################################
  1148. frame .systemResources
  1149.   frame .systemResources.registers
  1150.     frame .systemResources.registers.popslot -relief raised -borderwidth 2
  1151.     menubutton .systemResources.registers.popup -text "Registers" \
  1152.                 -menu .systemResources.registers.popup.menu 
  1153.       menu .systemResources.registers.popup.menu
  1154.       .systemResources.registers.popup.menu add command -label "Alter..." \
  1155.           -command {AlterRegister}
  1156.       .systemResources.registers.popup.menu add command -label "Clear All" \
  1157.           -command {ClearAllRegisters}
  1158.       .systemResources.registers.popup.menu add command -label "Description" \
  1159.           -command {ChildAlertDialog "" "Function not implemented yet!"}
  1160.     scrollbar .systemResources.registers.scroll -relief raised \
  1161.                -command ".systemResources.registers.list yview"
  1162.     listbox .systemResources.registers.list -relief raised \
  1163.              -yscroll ".systemResources.registers.scroll set"
  1164.     tk_listboxSingleSelect .systemResources.registers.list
  1165.     bind .systemResources.registers.list <Double-1> "AlterRegister"
  1166.  
  1167.     pack .systemResources.registers.popup -side top \
  1168.           -in .systemResources.registers.popslot
  1169.     pack .systemResources.registers.popslot -side top -fill x
  1170.     pack .systemResources.registers.scroll -side left -fill y
  1171.     pack .systemResources.registers.list -side left -fill y 
  1172.  
  1173.  
  1174.   frame .systemResources.statistics
  1175.     frame .systemResources.statistics.popslot -relief raised -borderwidth 2
  1176.     menubutton .systemResources.statistics.popup -text "Statistics" \
  1177.                 -menu .systemResources.statistics.popup.menu 
  1178.       menu .systemResources.statistics.popup.menu
  1179.       .systemResources.statistics.popup.menu add command -label "Clear All" \
  1180.           -command {ClearStatistics}
  1181.     scrollbar .systemResources.statistics.scroll -relief raised \
  1182.                -command ".systemResources.statistics.list yview"
  1183.     listbox .systemResources.statistics.list -relief raised \
  1184.              -yscroll ".systemResources.statistics.scroll set"
  1185.     tk_listboxSingleSelect .systemResources.statistics.list
  1186.  
  1187.  
  1188.     pack .systemResources.statistics.popup -side top \
  1189.           -in .systemResources.statistics.popslot
  1190.     pack .systemResources.statistics.popslot -side top -fill x
  1191.     pack .systemResources.statistics.scroll -side left -fill y
  1192.     pack .systemResources.statistics.list -side left -fill y
  1193.  
  1194.   pack .systemResources.registers -side left -fill y
  1195.   pack .systemResources.statistics -side left -fill y
  1196.  
  1197. ###############################################################################
  1198. # Build the Control area
  1199. ###############################################################################
  1200. frame .systemControl
  1201.   button .systemControl.singleStep -text "Single Step" \
  1202.       -command {Step "1"}
  1203.   button .systemControl.step -text "Step"\
  1204.       -command {Step "10"}
  1205.   button .systemControl.run -text "Run" \
  1206.       -command {Run}
  1207.   button .systemControl.breakpoints -text "Breakpoints" \
  1208.       -command {Breakpoints}
  1209.  
  1210.   pack .systemControl.singleStep -side left -expand 1 -fill x
  1211.   pack .systemControl.step -side left -expand 1 -fill x
  1212.   pack .systemControl.run -side left -expand 1 -fill x
  1213.   pack .systemControl.breakpoints -side left -expand 1 -fill x
  1214.  
  1215.  
  1216. ###############################################################################
  1217. # Build the Output/Trace area
  1218. ###############################################################################
  1219. frame .systemOutput
  1220.   frame .systemOutput.popslot -relief raised -borderwidth 2
  1221.   menubutton .systemOutput.popup -text "Trace" -menu .systemOutput.popup.menu 
  1222.     menu .systemOutput.popup.menu
  1223.     .systemOutput.popup.menu add command -label "Save Contents..." \
  1224.         -command {SaveTraceContents}
  1225.     .systemOutput.popup.menu add command -label "Clear Contents" \
  1226.         -command {.systemOutput.text delete 1.0 end}
  1227.     .systemOutput.popup.menu add separator
  1228.     .systemOutput.popup.menu add command -label "Insert Registers" \
  1229.         -command {InsertRegistersInTrace}
  1230.     .systemOutput.popup.menu add command -label "Insert Statistics" \
  1231.         -command {InsertStatisticsInTrace}
  1232.     .systemOutput.popup.menu add separator
  1233.     .systemOutput.popup.menu add command -label "Trace Preferences..." \
  1234.         -command {TracePreferences}
  1235.   scrollbar .systemOutput.scroll -relief raised \
  1236.       -command ".systemOutput.text yview"
  1237.   text .systemOutput.text -relief raised -wrap none \
  1238.       -yscroll ".systemOutput.scroll set" -borderwidth 2
  1239.     bind .systemOutput.text <Any-KeyPress> "NOP"
  1240.  
  1241.   pack .systemOutput.popup -side top \
  1242.         -in .systemOutput.popslot
  1243.   pack .systemOutput.popslot -side top -fill x
  1244.   pack .systemOutput.scroll -side left -fill y
  1245.   pack .systemOutput.text -side left -fill both -expand 1
  1246.  
  1247. pack .mainMenu -side top -fill x
  1248. pack .systemResources -side left -fill y
  1249. pack .systemControl -side bottom -fill x
  1250. pack .systemOutput -side bottom -expand 1 -fill both 
  1251.  
  1252. SetApplicationMode {StartupMode}
  1253. ParseCommandLineArguments
  1254.  
  1255.  
  1256.